package pub.guoxin.oops.common.protocol.adapter;

import lombok.Getter;
import lombok.Setter;
import pub.guoxin.oops.common.protocol.builder.DataProtocolCommandRegister;
import pub.guoxin.oops.common.protocol.entity.map.DataProtocolCommandMap;

/**
 * Created by guoxin on 18-3-8.
 */
@Getter
@Setter
public abstract class AbstractDataProtocolCommandAdapter {

    private DataProtocolCommandMap protocolCommandMap = DataProtocolCommandMap.newDataProtocolCommandMap();

    public abstract DataProtocolCommandRegister register(DataProtocolCommandRegister register);

    private DataProtocolCommandRegister register0(DataProtocolCommandRegister register) {
        DataProtocolCommandRegister result = register(register);
        this.protocolCommandMap.putAll(result.getRegister());
        return result;
    }

    public DataProtocolCommandMap build() {
        this.register0(new DataProtocolCommandRegister());
        return protocolCommandMap;
    }
}
